﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登录页面</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="js/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
	<form name="loginForm" method="post">
		<table>
			<tr>
				<td>用户名：</td>
				<td><input id="username" name="username" /></td>
			</tr>
			<tr>
				<td>密 码：</td>
				<td><input type="password" id="pwd" name="pwd" /><a href="#">忘记密码?</a></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="提交"
					onclick="validate()" /> <input type="button" value="重置" /></td>
			</tr>
		</table>
	</form>

	<script type="text/javascript">
		function validate(){
			var username = $("#username");
			if(username == null || username.val() == ""){
				alert("用户名不能为空！");
				username.focus();
				return;
			}
			var pwd = $("#pwd");
			if(pwd == null || pwd.val() == ""){
				alert("密码不能为空！");
				pwd.focus();
				return;
			}
			login(username,pwd);
		}
	
		function login(username,pwd) {
			$.ajax({
				url : "admin/login",
				method : "post",
				data : {
					userName : username.val(),
					pwd:pwd.val()
				},
				dataType : 'json',
				success : function(text) {
					alert(text);
				}
			});
		}
		
	</script>
</body>
</html>